/*--------------------------------------------------------------------------------
 * Adaptive Intelligence - Foundation Framework
 * Version 2.10
 * 
 * SQL Parameter Event Arguments Class
 *      Provides an event arguments definition for SQL Parameter related events.
 *------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------
 * System Imports
 *------------------------------------------------------------------------------*/
using System;
using System.Data;
using System.Data.Common;

namespace Adaptive.Foundation.Data
{
    /// <summary>
    /// Provides an event arguments definition for SQL Parameter related events.
    /// </summary>
    public class SqlParameterEventArgs : EventArgs
    {
        /*--------------------------------------------------------------------------------
		 * Private Member Declarations
		 *------------------------------------------------------------------------------*/
        #region Private Member Declarations
        /// <summary>
        /// The data parameter instance being referred to.
        /// </summary>
        private IDataParameter _parameter;
        /// <summary>
        /// The name of the parameter.
        /// </summary>
        private string _name;
        /// <summary>
        /// The data type of the parameter.
        /// </summary>
        private DbType _dataType;
        /// <summary>
        /// Parameter data container.
        /// </summary>
        private object _parameterData;
        #endregion

        /*--------------------------------------------------------------------------------
         * Constructor / Dispose / Destructor Methods
		 *------------------------------------------------------------------------------*/
        #region Constructor / Dispose / Destructor Methods
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <remarks>
        /// This is the default constructor.
        /// </remarks>
        /// <param name="parameter">
        /// The parameter being referred to.
        /// </param>
        public SqlParameterEventArgs(IDataParameter parameter)
            : base()
        {
            _parameter = parameter;
            if (parameter != null)
            {
                _name = _parameter.ParameterName;
                _dataType = _parameter.DbType;
            }
        }
        /// <summary>
        /// Initializes a new instance of the class to the specified name.
        /// </summary>
        /// <param name="parameterName">
        /// The name of the SQL parameter.
        /// </param>
        public SqlParameterEventArgs(string parameterName)
        {
            _name = parameterName;
        }
        /// <summary>
        /// Initializes a new instance of the class to the specified name.
        /// </summary>
        /// <param name="parameterName">
        /// The name of the SQL parameter.
        /// </param>
        /// <param name="dataType">
        /// The data type for the parameter.
        /// </param>
        public SqlParameterEventArgs(string parameterName, DbType dataType)
        {
            _name = parameterName;
            _dataType = dataType;
        }
        /// <summary>
        /// Class destructor.
        /// </summary>
        ~SqlParameterEventArgs()
        {
            _name = null;
            _parameter = null;
            _parameterData = null;
        }
        #endregion

        /*--------------------------------------------------------------------------------
	     * Public Properties
		 *------------------------------------------------------------------------------*/
        #region Public Properties
        /// <summary>
        /// Gets the reference to the data parameter instance being referred to.
        /// </summary>
        /// <value>
        /// An <see cref="IDataParameter"/> instance, or <b>null</b> if not supplied.
        /// </value>
        public IDataParameter Parameter
        {
            get{return _parameter;}
        }
        /// <summary>
        /// Gets or sets the name of the parameter.
        /// </summary>
        /// <value>
        /// The parameter name value.
        /// </value>
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        /// <summary>
        /// Gets or sets the data type of the parameter.
        /// </summary>
        /// <value>
        /// A <see cref="DbType"/> enumerated value indicating the data type of
        /// the parameter.
        /// </value>
        public DbType DataType
        {
            get { return _dataType; }
            set { _dataType = value; }

        }
        /// <summary>
        /// Gets or sets the data for the parameter instance.
        /// </summary>
        /// <value>
        /// The data to be contained in the parameter when executed.
        /// </value>
        public object ParameterData
        {
            get { return _parameterData; }
            set { _parameterData = value; }
        }
        #endregion
    }
}